do not use string-to-integer conversions without error handling#4906
Merged
danmar merged 11 commits intodanmar:mainfrom Apr 8, 2023
Merged
do not use string-to-integer conversions without error handling#4906danmar merged 11 commits intodanmar:mainfrom
danmar merged 11 commits intodanmar:mainfrom
Conversation
Collaborator
Author
|
The string we convert in |
508f7e8 to
be35a05
Compare
Collaborator
Author
|
I filed https://trac.cppcheck.net/ticket/11631 about the |
firewave
referenced
this pull request
Apr 2, 2023
…in `AstNode::setLocations()`
…ppcheckGuiProject()`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I came across this in preparation of improving the error location of
MathLib::to*(). I also wanted to improve the argument validation inCmdLineParserfor a while now.atoi()will return0if the conversion fails without any indication.std::istringstreamusage needs to be checked and it can overflow without error which can leading to wrong results. It also behaves differently with Visual Studio. See https://trac.cppcheck.net/ticket/10180 and https://trac.cppcheck.net/ticket/10181.We also use(d)
MathLib::to*Long()for non-literal conversions which required us to allow inputs which are not literals. I have not rolled back those changes yet since I still need to identify the changes. As I have a few more other tests cases to add I will do that in a different PR.The enabled clang-tidy check warns about
atoi()usage - see https://clang.llvm.org/extra/clang-tidy/checks/cert/err34-c.html.